<template>
  <yplayout>
    <template #header="props">
      <div class="flex items-center">
        <i class="ri-2x text-gray-500 ml-2" :class="props.meta.icon||'ri-information-line'"></i>
        <div class="text-xl px-2">增加图标</div>
      </div>
    </template>
    <template #list>
      <div class="overflow-auto bg-white select-none p-2">
        <div class="flex">
          <div class="w-24 text-right pr-5">名称</div>
          <div class="flex-1">
            <ypinput v-model="formData.title"></ypinput>
          </div>
        </div>
        <div class="flex py-2">
          <div class="w-24 text-right pr-5">字符</div>
          <div class="flex-1">
            <ypinput v-model="formData.name"></ypinput>
          </div>
        </div>
      </div>

      <div class="flex justify-center py-3 space-x-2">
        <button class="btn btn-hong" type="button" @click="save">
          <i class="ri-save-line ri-lg pr-1"></i>
          提交
        </button>
        <router-link to="list" class="btn">返回</router-link>
      </div>
    </template>
  </yplayout>
</template>
<script setup>
import {postData,alter} from "@/common/base"
import { ref, reactive } from 'vue'
const emit = defineEmits(['jumpCom'])
const formData = reactive({
  title: '',
  name: '',
  mclass_id:0
})
const isreset = ref(0)
const save = async () => {
  const res= await postData('icon/save', formData)
  if(res.code) {
    alter({ type: 'alter-success', text: res.msg })
    setTimeout(() => {
      reset()
    }, 1000)
  }
}
const reset = () => {
  isreset.value = 1
  for (let key in formData) {
    formData[key] = ''
  }
}
</script>